{% extends 'user_layout.html' %}

{% block lk %}
    {% load static %}
    <title>用户订单</title>
    <link rel="stylesheet" href="{% static 'plugins/bootstrap-3.4.1/css/bootstrap.min.css' %}">
{% endblock %}

{% block content_user%}
    <h3 class="common_title2">全部订单</h3>
        {% for item in order_data %}
        <ul class="order_list_th w978 clearfix" style="background-color: #4cae4c">
            <li class="col01" style="color: white">{{ item.0.creat_time }}</li>
            <li class="col02" style="color: white">订单号：{{ item.0.oid }}</li>
            <li class="col02 stress" style="color: red">{{ item.0.get_order_status_display }}</li>
            {% if item.0.order_status != 1 %}
                <li class="col03" >
                    <a style="color: white" href="http://127.0.0.1:8000/detail/{{ item.0.good_id }}/" class="btn_cancel_order">前往评价</a>
                </li>
            {% endif %}
        </ul>

        <table class="order_list_table w980">
            <tbody>
                <tr>
                    <td width="55%">
                        <ul class="order_goods_list clearfix">
                            <li class="col01"><img src="/static/img/{{ item.1.img }}"></li>
                            <li class="col02">{{ item.1.title }}<em>{{ item.1.price }}元/500g</em></li>
                            <li class="col03">{{ item.0.number }}</li>
                            <li class="col04">单价：{{ item.1.price }}元</li>
                        </ul>
                    </td>
                    <td width="15%">总计：{{ item.0.price }}元</td>
                    <td width="15%">{{ item.0.get_order_status_display }}</td>
                    {% if item.0.order_status == 1 %}
                        <td width="15%"><a href="http://127.0.0.1:8000/alipay/{{ item.0.id }}/" class="oper_btn" style="background-color: #4cae4c;color: white">去付款</a>
                        <input uid="{{ item.0.id }}" class="btn btn-danger btn-xs btn-delete"  type="button" value="取消" style="background-color: red;color: white;border-color: red;height: 25px;width: 35px">
                        </td>
                    {% endif %}
                </tr>
            </tbody>
        </table>
        {% endfor %}

         <div class="sort_bar">

            <ul class="pagination">
            {{ page_string }}
            </ul>

         </div>


{% endblock %}
{% block js %}
    <script type="text/javascript">

        $('.btn-delete').click(function (){

           var uid = $(this).attr('uid');
            $.ajax({
                url: "/delete/order/",
                type: 'GET',
                data: {
                    uid: uid,
                },
                dataType: 'JSON',
                    success: function (res){
                        if(res.status){
                            location.reload();
                        }
                    }

            })

        })




    </script>

{% endblock %}